<?php
session_start();
$usuario = $_SESSION['S_USUARIO'];
if ($usuario == "") {
	echo "<font face='Tahoma' size='2' color='red'><b>SESION CERRADA POR EL USUARIO!</b></font>";
	exit;
}
require '../include/class.eyemysqladap.inc.php';
require '../include/class.eyedatagrid.inc.php';

// Load the database adapter
$db = new EyeMySQLAdap('localhost', 'root', 'root', 'fed');

// Load the datagrid class
$x = new EyeDataGrid($db);

// Set the query
$x->setQuery("iddatos,cedula,apellidos,nombres,telefono_part,telefono_lab,telefono_cel,email", "datospersonales", 'iddatos',"borrado='0'");

// Allows filters
$x->allowFilters();

// Change headers text
$x->setColumnHeader('cedula', 'Cedula');
$x->setColumnHeader('telefono_part', 'Tel.Baja');
$x->setColumnHeader('telefono_lab', 'Tel.Lab.');
$x->setColumnHeader('telefono_cel', 'Movil');
$x->setColumnHeader('apellidos', 'Apellidos');
$x->setColumnHeader('nombres', 'Nombres');
$x->setColumnHeader('email', 'Email');
// Hide ID Column
$x->hideColumn('iddatos');

// Change column type
/*$x->setColumnType('FirstName', EyeDataGrid::TYPE_HREF, 'http://google.com/search?q=%FirstName%'); // Google Me!
$x->setColumnType('BirthDate', EyeDataGrid::TYPE_DATE, 'M d, Y', true); // Change the date format
$x->setColumnType('Gender', EyeDataGrid::TYPE_ARRAY, array('m' => 'Male', 'f' => 'Female')); // Convert db values to something better
$x->setColumnType('Done', EyeDataGrid::TYPE_PERCENT, false, array('Back' => '#c3daf9', 'Fore' => 'black'));
*/
// Show reset grid control
$x->showReset();

// Add custom control, order does matter
//$x->addCustomControl(EyeDataGrid::CUSCTRL_TEXT, "alert('%FirstName%\'s been promoted!')", EyeDataGrid::TYPE_ONCLICK, 'Promote Me');

// Add standard control
$x->addStandardControl(EyeDataGrid::STDCTRL_EDIT, "location.href='modificar.php?id=%_P%'");
$x->addStandardControl(EyeDataGrid::STDCTRL_DELETE, "if (confirm('Desea borrar el registro ID %_P%')){location.href='guardar.php?accion=baja&id=%_P%'}else{return;}");


// Add create control
$x->showCreateButton("nuevo()", EyeDataGrid::TYPE_ONCLICK, 'Nuevo');

// Show checkboxes
$x->showCheckboxes();

// Show row numbers
$x->showRowNumber();

// Apply a function to a row
function returnSomething($lastname)
{
	return strrev($lastname);
}
$x->setColumnType('LastName', EyeDataGrid::TYPE_FUNCTION, 'returnSomething', '%LastName%');

if (EyeDataGrid::isAjaxUsed())
{
	$x->printTable();
	exit;
}
?>
<html>
<head>
<title>EyeDataGrid Example 5</title>
<link href="../estilos/table.css" rel="stylesheet" type="text/css">
<script language="javascript">
function nuevo(){
	location.href="nuevo.php";
}

</script>
</head>
<body>
<h3>Movimiento Dignidad Liberal	</h3>
<ul>
  <li>FORMULARIO PARA CANDIDATOS A OCUPAR CARGOS DE ENCARGADOS DE URNA Y VEEDORES</li>
</ul>
<?php
// Print the table
EyeDataGrid::useAjaxTable();
?>
</body>
</html>